Skip to main content

ChartComponent

ChartComponent API

ChartComponent.doActivate
ChartComponent.doActivate(): void

This method overrides the doActivate method of the parent class and calls it. It does not take any parameters and does not return anything.

Returns
void
ChartComponent.registerDefaultCandlesTransformers
ChartComponent.registerDefaultCandlesTransformers(): void

Registers default candle transformers.

Returns
void
ChartComponent.registerCandlesTransformer
ChartComponent.registerCandlesTransformer(chartType: keyof BarTypes, transformer: VisualCandleCalculator): void

You can use this method to determine logic of visual candle transformation for specified chart type.

Parameters
chartType: keyof BarTypes
transformer: VisualCandleCalculator
Returns
void
ChartComponent.registerLastCandleLabelHandler
ChartComponent.registerLastCandleLabelHandler(chartType: keyof BarTypes, handler: LastCandleLabelHandler): void

You can use this method to modify labels for last candle.

Parameters
chartType: keyof BarTypes
handler: LastCandleLabelHandler
Returns
void
ChartComponent.registerCandlesWidthCalculator
ChartComponent.registerCandlesWidthCalculator(chartType: keyof BarTypes, calculator: CandleWidthCalculator): void

You can use this method to determine chart width calculation for specified chart type.

Parameters
chartType: keyof BarTypes
calculator: CandleWidthCalculator
Returns
void
ChartComponent.registerDefaultDataSeriesDrawers
ChartComponent.registerDefaultDataSeriesDrawers(): void

In future this drawers should have same type as main series

Returns
void
ChartComponent.setChartType
ChartComponent.setChartType(type: keyof BarTypes): void

Sets the chart type of main candle series.

Parameters
type: keyof BarTypes
- new type
Returns
void
ChartComponent.resetChartScale
ChartComponent.resetChartScale(): void

Resets chart scale to default according to config.components.chart.defaultZoomCandleWidth.

Returns
void
ChartComponent.setTimestampRange
ChartComponent.setTimestampRange(start: number, end: number, forceNoAnimation: boolean): void

Sets the timestamp range of the chart by setting the x-axis scale.

Parameters
start: number
- The start timestamp of the range.
end: number
- The end timestamp of the range.
forceNoAnimation: boolean
- true by default
Returns
void
ChartComponent.setXScale
ChartComponent.setXScale(xStart: number, xEnd: number, forceNoAnimation: boolean): void

Moves the viewport to exactly xStart..xEnd place.

Parameters
xStart: number
- viewport start in units
xEnd: number
- viewport end in units
forceNoAnimation: boolean
- true by default
Returns
void
ChartComponent.setShowWicks
ChartComponent.setShowWicks(isShow: boolean): void

Sets the visibility of the wicks in the chart.

Parameters
isShow: boolean
- A boolean value indicating whether to show or hide the wicks.
Returns
void
ChartComponent.setApplyBackgroundToAxes
ChartComponent.setApplyBackgroundToAxes(options: { x: boolean; y: boolean; }): void

Sets the options for the background color applying to the chart axes

Parameters
options: { x: boolean; y: boolean; }
- options for both axes
Returns
void
ChartComponent.setMainSeries
ChartComponent.setMainSeries(series: CandleSeries): void

Used to set the main series to chart.

Parameters
series: CandleSeries
Returns
void
ChartComponent.setSecondarySeries
ChartComponent.setSecondarySeries(series: CandleSeries): CandleSeriesModel

Adds new secondary chart series.

Parameters
series: CandleSeries
Returns
CandleSeriesModel
ChartComponent.setAllSeries
ChartComponent.setAllSeries(mainSeries: CandleSeries, secondarySeries: CandleSeries[]): void

Sets the main and secondary series in one bulk operation. Reindexing and visual rerender happens at the same time.

Parameters
mainSeries: CandleSeries
secondarySeries: CandleSeries[]
Returns
void
ChartComponent.toXFromCandleIndex
ChartComponent.toXFromCandleIndex(idx: number): number

Converts candle index to chart x coordinate

Parameters
idx: number
Returns
number
ChartComponent.toXFromTimestamp
ChartComponent.toXFromTimestamp(timestamp: number): number

Converts timestamp to chart x coordinate

Parameters
timestamp: number
Returns
number
ChartComponent.toY
ChartComponent.toY(price: number): number

Converts price to chart y coordinate

Parameters
price: number
Returns
number
ChartComponent.updateAllSeries
ChartComponent.updateAllSeries(mainSeries: CandleSeries, secondarySeries: CandleSeries[]): void

Updates the main and secondary series in one bulk operation. Reindexing and visual rerender happens at the same time.

Parameters
mainSeries: CandleSeries
secondarySeries: CandleSeries[]
Returns
void
ChartComponent.removeDataFrom
ChartComponent.removeDataFrom(timestamp: number): void

Removes all data points from the main candle series that are newer than the given timestamp. Can be useful for data replay.

Parameters
timestamp: number
Returns
void
ChartComponent.removeSecondarySeries
ChartComponent.removeSecondarySeries(series: CandleSeriesModel): void

Removes chart candles series.

Parameters
series: CandleSeriesModel
Returns
void
ChartComponent.prependCandles
ChartComponent.prependCandles(target: Candle[], prependUpdate: Candle[]): void

Adds new candles array to the existing one at the start, mostly used in lazy loading

Parameters
target: Candle[]
- initial candles array
prependUpdate: Candle[]
- additional candles array, which will be added to the target array
Returns
void
ChartComponent.addLastCandle
ChartComponent.addLastCandle(candle: Candle, instrumentSymbol: string): void

Adds new candle to the chart

Parameters
candle: Candle
- new candle
instrumentSymbol: string
- name of the instrument to update
Returns
void
ChartComponent.removeCandleByIdx
ChartComponent.removeCandleByIdx(idx: number, instrumentSymbol: string): void

Remove candle by idx and recalculate indexes

Parameters
idx: number
- candle index
instrumentSymbol: string
- name of the instrument to update
Returns
void
ChartComponent.removeCandlesByIdsSequence
ChartComponent.removeCandlesByIdsSequence(ids: string[], selectedCandleSeries: CandleSeriesModel): void

Remove candles by ids and recalculate indexes, candles should be as a sequence, follow one by one Works faster than removeCandlesByIds

Parameters
ids: string[]
- candles ids to remove
selectedCandleSeries: CandleSeriesModel
- candle series to remove candles from
Returns
void
ChartComponent.removeCandlesByIds
ChartComponent.removeCandlesByIds(ids: string[], selectedCandleSeries: CandleSeriesModel): void

Remove candles by ids and recalculate indexes

Parameters
ids: string[]
- candles ids to remove
selectedCandleSeries: CandleSeriesModel
- candle series to remove candles from
Returns
void
ChartComponent.addCandlesById
ChartComponent.addCandlesById(candles: Candle[], startId: string, selectedCandleSeries: CandleSeriesModel): void

Add candles by id and recalculate indexes

Parameters
candles: Candle[]
- candles to add
startId: string
- target candle to start adding candles from
selectedCandleSeries: CandleSeriesModel
- candle series to add candles to
Returns
void
ChartComponent.updateLastCandle
ChartComponent.updateLastCandle(candle: Candle, instrumentSymbol: string): void

Updates last candle value

Parameters
candle: Candle
- updated candle
instrumentSymbol: string
- name of the instrument to update
Returns
void
ChartComponent.updateCandles
ChartComponent.updateCandles(candles: Candle[], instrumentSymbol: string): void

Updates candle series for instrument. By default takes main instrument.

Parameters
candles: Candle[]
instrumentSymbol: string
- name of the instrument to update
Returns
void
ChartComponent.setOffsets
ChartComponent.setOffsets(offsets: Partial<ChartConfigComponentsOffsets>): void

Sets offsets to viewport.

Parameters
offsets: Partial<ChartConfigComponentsOffsets>
- new offsets
Returns
void
ChartComponent.getDataSeriesDrawer
ChartComponent.getDataSeriesDrawer(drawerType: keyof BarTypes): SeriesDrawer

Returns a SeriesDrawer object based on the provided drawerType.

Parameters
drawerType: keyof BarTypes
- The type of the drawer to be returned.
Returns
SeriesDrawer
ChartComponent.registerDataSeriesTypeDrawer
ChartComponent.registerDataSeriesTypeDrawer(drawerType: string, drawer: SeriesDrawer): void

Registers a new chart type drawer or overrides default drawer if drawerType is {BarType}.

Parameters
drawerType: string
- a unique name for the drawer, could be {BarType} - in this case will override default drawer for the type
drawer: SeriesDrawer
- an implementation of the drawer
Returns
void
ChartComponent.updatePriceIncrementsIfNeeded
ChartComponent.updatePriceIncrementsIfNeeded(instrument: ChartInstrument): void

Updates the price increments of a given instrument if they are not valid or not defined. If the price increments are not valid or not defined, it will set them to a default value.

Parameters
instrument: ChartInstrument
- The instrument to update the price increments for.
Returns
void
ChartComponent.observeOffsetsChanged
ChartComponent.observeOffsetsChanged(): Observable<void>

Returns an Observable that emits a void value whenever the offsetsChanged event is triggered.

Returns
Observable<void>
ChartComponent.observeChartTypeChanged
ChartComponent.observeChartTypeChanged(): Observable<keyof BarTypes>

Returns an Observable that emits the BarType whenever the chart type is changed.

Returns
Observable<keyof BarTypes>
ChartComponent.observeCandlesChanged
ChartComponent.observeCandlesChanged(): Observable<void>

Returns an Observable that emits a void value when the candles in the chart model change. The Observable is obtained by calling the observeCandlesChanged method of the chartModel object.

Returns
Observable<void>
ChartComponent.observeCandlesUpdated
ChartComponent.observeCandlesUpdated(): Observable<void>

Returns an Observable that emits a void value when the candles are updated in the chart model. The Observable is obtained from the candlesUpdatedSubject of the chartModel.

Returns
Observable<void>
ChartComponent.observeCandlesPrepended
ChartComponent.observeCandlesPrepended(): Observable<PrependedCandlesData>

Returns an Observable that emits a void value whenever the candlesPrependSubject is triggered.

Returns
Observable<PrependedCandlesData>
;